package xyz.zhouzhaodong.springbootredisqueue.controller;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Redis操作类
 * @author zhouzhaodong
 */
@RestController
public class RedisController {

    private final RedisTemplate<String, String> redisTemplate;

    public RedisController(RedisTemplate<String, String> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @GetMapping("/publish")
    public void publish(@RequestParam String message) {
        // 发送消息
        // 下面这里需要配置发送的CHANNEL名称
        redisTemplate.convertAndSend("helloMessage", message);
    }

}
